<html><head><meta charset="gb2312"/><title>Sprite.pb</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font><font color="#3A3966">;   PureBasic - Sprite example file
</font><font color="#3A3966">;
</font><font color="#3A3966">;    (c) 2001 - Fantaisie Software
</font><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font>
<b><font color="#3A3966">If</font></b> <font color="#3A3966">InitSprite</font>() = 0 <b><font color="#3A3966">Or</font></b> <font color="#3A3966">InitKeyboard</font>() = 0
<font color="#3A3966">  MessageRequester</font>("Error", "Sprite system can't be initialized", 0)
  <b><font color="#3A3966">End</font></b>
<b><font color="#3A3966">EndIf</font></b>

<font color="#3A3966">;
</font><font color="#3A3966">; Now, open a 640*480 - 16 bits (65000 colours) screen
</font><font color="#3A3966">;
</font><b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenScreen</font>(640, 480, 16, "Sprite")

  <font color="#3A3966">; Load our 16 bit sprite (which is a 24 bit picture in fact, as BMP doesn't support 16 bit format)
</font>  <font color="#3A3966">; 
</font><font color="#3A3966">  LoadSprite</font>(0, "Data/PureBasic.bmp", 0)
<font color="#3A3966">  CopySprite</font>(0,1,0)
  
  <b><font color="#3A3966">Repeat</font></b>
    
    <font color="#3A3966">; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back)
</font>    
<font color="#3A3966">    FlipBuffers</font>()
    
<font color="#3A3966">    ClearScreen</font>(<font color="#3A3966">RGB</font>(0,0,0))
    
    <font color="#3A3966">; Draw our sprite
</font>
<font color="#3A3966">    ClipSprite</font>(0, 0, 0, x, x/8)
     
<font color="#3A3966">    DisplaySprite</font>(0, x, 100)
<font color="#3A3966">    DisplaySprite</font>(1, x, x)
<font color="#3A3966">    DisplaySprite</font>(0, 600-x, x)
    
    x+1
    
<font color="#3A3966">    ExamineKeyboard</font>()
  <b><font color="#3A3966">Until</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Escape</font>)
  
<b><font color="#3A3966">Else</font></b>
<font color="#3A3966">  MessageRequester</font>("Error", "Can't open a 640*480 - 16 bit screen !", 0)
<b><font color="#3A3966">EndIf</font></b>

<b><font color="#3A3966">End</font></b>    </font></pre>
</body></html>
